home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HPAVC
/
HPAVC CD-ROM.iso
/
PASANS.ZIP
/
CH08_1.PAS
< prev
next >
Wrap
Pascal/Delphi Source File
|
1991-02-04
|
2KB
|
63 lines
(* Chapter 8 - Programming exercise 1 *)
program Find_All_Upper_Case_Characters;
const String_Size = 30;
type Upper_Set = set of 'A'..'Z';
var Data_Set : Upper_Set;
Storage : string[String_Size];
Index : 1..String_Size;
Print_Group : string[26];
begin (* main program *)
Data_Set := [];
Print_Group := '';
Storage := 'This Is A Set Test.';
for Index := 1 to Length(Storage) do begin
if Storage[Index] in ['A'..'Z'] then begin
if Storage[Index] in Data_Set then
Writeln(Index:4,' ',Storage[Index],
' is already in the set')
else begin
Data_Set := Data_Set + [Storage[Index]];
Print_Group := Print_Group + Storage[Index];
Writeln(Index:4,' ',Storage[Index],
' added to group, complete group = ',
Print_Group);
end;
end
else
Writeln(Index:4,' ',Storage[Index],
' is not an upper case letter');
end;
end. (* of main program *)
{ Result of execution
1 T added to group, complete group = T
2 h is not an upper case letter
3 i is not an upper case letter
4 s is not an upper case letter
5 is not an upper case letter
6 I added to group, complete group = TI
7 s is not an upper case letter
8 is not an upper case letter
9 A added to group, complete group = TIA
10 is not an upper case letter
11 S added to group, complete group = TIAS
12 e is not an upper case letter
13 t is not an upper case letter
14 is not an upper case letter
15 T is already in the set
16 e is not an upper case letter
17 s is not an upper case letter
18 t is not an upper case letter
19 . is not an upper case letter
}